package org.example;

public class Test1 {
    //leetcode 530 二叉搜索树的最小绝对差 https://leetcode.cn/problems/minimum-absolute-difference-in-bst/description/
    public int prev,min;
    public int getMinimumDifference(TreeNode root) {
        min = 0x3f3f3f3f;
        prev = -(int)1e5;
        getMinimumDifferenceChild(root);
        return min;
    }

    public void getMinimumDifferenceChild(TreeNode root) {
        if (root == null) return;
        getMinimumDifferenceChild(root.left);
        min = Math.min(min,root.val - prev);
        prev = root.val;
        getMinimumDifferenceChild(root.right);
    }
}
